﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;

using CE.Mail;
using CE.Image;
using CE.Global;
using CE.Database;
using CE.CreditCard;
using CE.User;
using CE.PostCode;
using CE.CarInsurance;
using CE.Provider;
using CE.Security;
using CE.InputOut;
using CE.StreetDirectory;
using CE.Payment;

public partial class car_insurance_new_proposalforms_rsa_proposal_form : System.Web.UI.Page
{
    public static Int64 _CarId, _CarMoreId, _UserId, _CXCTypeId, _ProviderId;
    public static DateTime _dtDOB1 = CE.Global.General.GetUTCDateTime();
    public static DateTime _dtDOB2 = CE.Global.General.GetUTCDateTime();
    public static DateTime _dtDOB3 = CE.Global.General.GetUTCDateTime();
    public static DateTime _dtDOB4 = CE.Global.General.GetUTCDateTime();
    public static DateTime _dtDOB5 = CE.Global.General.GetUTCDateTime();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] != null && Session[CE.Global.General.UserTypeId] != null)
        {
            if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                 Convert.ToInt32(CE.Global.CEUserType.Customer) && Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                 Convert.ToInt32(CE.Global.CEUserType.Provider))
            {
                Response.Redirect("~/car-insurance/login.aspx");
            }
        }
        else
        {
            Response.Redirect("~/car-insurance/login.aspx");
        }

        if (Session[General.CarId] == null || Session[General.CarPolicyId] == null)
        {
            Response.Redirect("~/car-insurance/profile.aspx");
        }

        if (Session[CE.Global.General.CarResultId] != null)
        {
            if (Session[General.ProviderCompanyId].ToString() != "24")
            {
                Response.Redirect("~/user/viewresulthistory.aspx");
            }
        }
        else
        {
            Response.Redirect("~/user/viewresulthistory.aspx");
        }

        if (!IsPostBack)
        {
            lblDisclaimer.Text = CE.Configuration.MyConfigurationManager.GetAppSettingValue("RSACarProposalDisclaimer");
            
            
            #region Date Start & End

            ddlDODemerit1.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit1.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit2.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit2.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit3.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit3.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit4.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit4.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit5.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit5.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit6.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit6.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDOCancellation.StartYear = CE.Global.General.GetUTCDateTime().Year - 10;
            ddlDOCancellation.EndYear = CE.Global.General.GetUTCDateTime().Year;


            int _ccyear;
            int ccstartyear = CE.Global.General.GetUTCDateTime().Year;
            int ccendyear = CE.Global.General.GetUTCDateTime().Year + 10;
            for (_ccyear = ccendyear; _ccyear >= ccstartyear; _ccyear--)
            {
                ddlCardExpiryYear.Items.Insert(0, new ListItem(_ccyear.ToString("0000"), _ccyear.ToString("00")));
            }
            ddlCardExpiryYear.Items.Insert(0, new ListItem("yyyy", "-1"));


            int _year;
            int startyear = CE.Global.General.GetUTCDateTime().Year;
            int endyear = CE.Global.General.GetUTCDateTime().Year - 50;
            for (_year = endyear; _year <= startyear; _year++)
            {
                ddlYearObtained.Items.Insert(0, new ListItem(_year.ToString("0000"), _year.ToString("0000")));
                ddlDriverYearObtained1.Items.Insert(0, new ListItem(_year.ToString("0000"), _year.ToString("0000")));
                ddlDriverYearObtained2.Items.Insert(0, new ListItem(_year.ToString("0000"), _year.ToString("0000")));
                ddlDriverYearObtained3.Items.Insert(0, new ListItem(_year.ToString("0000"), _year.ToString("0000")));
                ddlDriverYearObtained4.Items.Insert(0, new ListItem(_year.ToString("0000"), _year.ToString("0000")));
                ddlDriverYearObtained5.Items.Insert(0, new ListItem(_year.ToString("0000"), _year.ToString("0000")));
            }
            ddlYearObtained.Items.Insert(0, new ListItem("YYYY", "-1"));
            ddlDriverYearObtained1.Items.Insert(0, new ListItem("YYYY", "-1"));
            ddlDriverYearObtained2.Items.Insert(0, new ListItem("YYYY", "-1"));
            ddlDriverYearObtained3.Items.Insert(0, new ListItem("YYYY", "-1"));
            ddlDriverYearObtained4.Items.Insert(0, new ListItem("YYYY", "-1"));
            ddlDriverYearObtained5.Items.Insert(0, new ListItem("YYYY", "-1"));

            #endregion

            #region Load Combo

            InsurerDB _insurerdb = new InsurerDB();
            DataTable dtPreInsurerBank = _insurerdb.GetPreInsurer(100, 2);
            ddlHirePurchaseCompany.DataSource = dtPreInsurerBank;
            ddlHirePurchaseCompany.DataTextField = dtPreInsurerBank.Columns[0].ColumnName.ToString();
            ddlHirePurchaseCompany.DataValueField = dtPreInsurerBank.Columns[1].ColumnName.ToString();
            ddlHirePurchaseCompany.DataBind();
            ddlHirePurchaseCompany.Items.Insert(0, new ListItem("Select", "-1"));


            DataTable dtPreInsurerCo = _insurerdb.GetPreInsurer(100, 1);
            ddlExistingInsurerName.DataSource = dtPreInsurerCo;
            ddlExistingInsurerName.DataTextField = dtPreInsurerCo.Columns[0].ColumnName.ToString();
            ddlExistingInsurerName.DataValueField = dtPreInsurerCo.Columns[1].ColumnName.ToString();
            ddlExistingInsurerName.DataBind();
            ddlExistingInsurerName.Items.Insert(0, new ListItem("Select", "-1"));

            #endregion

            #region Validation Effect

            txtName.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtName.ClientID + "','" + rfvName.ClientID + "','" + revName.ClientID + "')");
            txtPostCode.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtPostCode.ClientID + "','" + rfvPostCode.ClientID + "','" + revPostCode.ClientID + "')");
            txtUnit1.Attributes.Add("onblur", "ShowValidationEffect('" + txtUnit1.ClientID + "','" + rfvUnit1.ClientID + "')");
            txtUnit2.Attributes.Add("onblur", "ShowValidationEffect('" + txtUnit2.ClientID + "','" + rfvUnit2.ClientID + "')");
            txtAddress.Attributes.Add("onblur", "ShowValidationEffect('" + txtAddress.ClientID + "','" + rfvAddress.ClientID + "')");
            txtDrivingLicenceNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtDrivingLicenceNo.ClientID + "','" + rfvDrivingLicenceNo.ClientID + "')");
            txtDrivingClass.Attributes.Add("onblur", "ShowValidationEffect('" + txtDrivingClass.ClientID + "','" + rfvDrivingClass.ClientID + "')");
            ddlYearObtained.Attributes.Add("onblur", "ShowValidationEffect('" + ddlYearObtained.ClientID + "','" + rfvYearObtained.ClientID + "')");

            txtVehicleNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtVehicleNo.ClientID + "','" + rfvVehicleNo.ClientID + "')");
            txtEngineNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtEngineNo.ClientID + "','" + rfvEngineNo.ClientID + "')");
            txtChassisNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtChassisNo.ClientID + "','" + rfvChassisNo.ClientID + "')");

            ddlVehicleTransmission.Attributes.Add("onblur", "ShowValidationEffect('" + ddlVehicleTransmission.ClientID + "','" + rfvVehicleTransmission.ClientID + "')");
            ddlVehiclePropellant.Attributes.Add("onblur", "ShowValidationEffect('" + ddlVehiclePropellant.ClientID + "','" + rfvVehiclePropellant.ClientID + "')");
            txtVehicleSumInsured.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtVehicleSumInsured.ClientID + "','" + rfvVehicleSumInsured.ClientID + "','" + revVehicleSumInsured.ClientID + "')");
            txtClaimODAmount.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtClaimODAmount.ClientID + "','" + rfvClaimODAmount.ClientID + "','" + revClaimODAmount.ClientID + "')");
            txtClaimTPPDAmount.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtClaimTPPDAmount.ClientID + "','" + rfvClaimTPPDAmount.ClientID + "','" + revClaimTPPDAmount.ClientID + "')");

            ddlHirePurchaseCompany.Attributes.Add("onblur", "ShowValidationEffect('" + ddlHirePurchaseCompany.ClientID + "','" + rfvHirePurchaseCompany.ClientID + "')");
            ddlDrivetowestmalaysia.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDrivetowestmalaysia.ClientID + "','" + rfvDrivetowestmalaysia.ClientID + "')");
            txtVMReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtVMReason.ClientID + "','" + rfvVMReason.ClientID + "')");
            txtSunroofExtenAmt.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtSunroofExtenAmt.ClientID + "','" + rfvSunroofExtenAmt.ClientID + "','" + revSunroofExtenAmt.ClientID + "')");
            txtMoonroofExtenAmt.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtMoonroofExtenAmt.ClientID + "','" + rfvMoonroofExtenAmt.ClientID + "','" + revMoonroofExtenAmt.ClientID + "')");

            txtPIReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtPIReason.ClientID + "','" + rfvPIReason.ClientID + "')");
            txtAIReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtAIReason.ClientID + "','" + rfvAIReason.ClientID + "')");
            txtTCReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtTCReason.ClientID + "','" + rfvTCReason.ClientID + "')");
            txtITReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtITReason.ClientID + "','" + rfvITReason.ClientID + "')");
            ddlExistingInsurerName.Attributes.Add("onblur", "ShowValidationEffect('" + ddlExistingInsurerName.ClientID + "','" + rfvExistingInsurerName.ClientID + "')");
            txtInsRegisterNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtInsRegisterNo.ClientID + "','" + rfvInsRegisterNo.ClientID + "')");
            ddlExistNCD.Attributes.Add("onblur", "ShowValidationEffect('" + ddlExistNCD.ClientID + "','" + rfvExistNCD.ClientID + "')");
            txtInsPolicyNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtInsPolicyNo.ClientID + "','" + rfvInsPolicyNo.ClientID + "')");

            txtDriverName1.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverName1.ClientID + "','" + rfvDriverName1.ClientID + "')");
            txtDriverDrivingClass1.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverDrivingClass1.ClientID + "','" + rfvDriverDrivingClass1.ClientID + "')");
            ddlDriverYearObtained1.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDriverYearObtained1.ClientID + "','" + rfvDriverYearObtained1.ClientID + "')");
            txtDriverName2.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverName2.ClientID + "','" + rfvDriverName2.ClientID + "')");
            txtDriverDrivingClass2.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverDrivingClass2.ClientID + "','" + rfvDriverDrivingClass2.ClientID + "')");
            ddlDriverYearObtained2.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDriverYearObtained2.ClientID + "','" + rfvDriverYearObtained2.ClientID + "')");
            txtDriverName3.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverName3.ClientID + "','" + rfvDriverName3.ClientID + "')");
            txtDriverDrivingClass3.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverDrivingClass3.ClientID + "','" + rfvDriverDrivingClass3.ClientID + "')");
            ddlDriverYearObtained3.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDriverYearObtained3.ClientID + "','" + rfvDriverYearObtained3.ClientID + "')");
            txtDriverName4.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverName4.ClientID + "','" + rfvDriverName4.ClientID + "')");
            txtDriverDrivingClass4.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverDrivingClass4.ClientID + "','" + rfvDriverDrivingClass4.ClientID + "')");
            ddlDriverYearObtained4.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDriverYearObtained4.ClientID + "','" + rfvDriverYearObtained4.ClientID + "')");
            txtDriverName5.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverName5.ClientID + "','" + rfvDriverName5.ClientID + "')");
            txtDriverDrivingClass5.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverDrivingClass5.ClientID + "','" + rfvDriverDrivingClass5.ClientID + "')");
            ddlDriverYearObtained5.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDriverYearObtained5.ClientID + "','" + rfvDriverYearObtained5.ClientID + "')");

            txtNameoftheCard.Attributes.Add("onblur", "ShowValidationEffect('" + txtNameoftheCard.ClientID + "','" + rfvNameoftheCard.ClientID + "')");
            txtIssuingBank.Attributes.Add("onblur", "ShowValidationEffect('" + txtIssuingBank.ClientID + "','" + rfvIssuingBank.ClientID + "')");
            txtCardNo1.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo1.ClientID + "','" + rfvCardNo1.ClientID + "','" + revCardNo1.ClientID + "')");
            txtCardNo2.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo2.ClientID + "','" + rfvCardNo2.ClientID + "','" + revCardNo2.ClientID + "')");
            txtCardNo3.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo3.ClientID + "','" + rfvCardNo3.ClientID + "','" + revCardNo3.ClientID + "')");
            txtCardNo4.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo4.ClientID + "','" + rfvCardNo4.ClientID + "','" + revCardNo4.ClientID + "')");
            ddlCardExpiryMonth.Attributes.Add("onblur", "ShowValidationEffect('" + ddlCardExpiryMonth.ClientID + "','" + rfvCardExpiryMonth.ClientID + "')");
            ddlCardExpiryYear.Attributes.Add("onblur", "ShowValidationEffect('" + ddlCardExpiryYear.ClientID + "','" + rfvCardExpiryYear.ClientID + "')");

            txtDemeritDrivername1.Attributes.Add("onblur", "ShowValidationEffect('" + txtDemeritDrivername1.ClientID + "','" + rfvDemeritDrivername1.ClientID + "')");
            txtTotalpoints1.Attributes.Add("onblur", "ShowValidationEffect('" + txtTotalpoints1.ClientID + "','" + rfvTotalpoints1.ClientID + "')");
            txtOffencetype1.Attributes.Add("onblur", "ShowValidationEffect('" + txtOffencetype1.ClientID + "','" + rfvOffencetype1.ClientID + "')");

            rdoYesHirePurchase.Attributes.Add("onblur", "CheckHirePurchaseValidationCss();");
            rdoNoHirePurchase.Attributes.Add("onblur", "CheckHirePurchaseValidationCss();");
            rdoYesDrivingWestMalaysia.Attributes.Add("onblur", "CheckDrivingWestMalaysiaValidationCss();");
            rdoNoDrivingWestMalaysia.Attributes.Add("onblur", "CheckDrivingWestMalaysiaValidationCss();");
            rdoYesVechicleModification.Attributes.Add("onblur", "CheckVechicleModificationValidationCss();");
            rdoNoVechicleModification.Attributes.Add("onblur", "CheckVechicleModificationValidationCss();");
            rdoYesCOE.Attributes.Add("onblur", "CheckMarketvalueValidationCss();");
            rdoNoCOE.Attributes.Add("onblur", "CheckMarketvalueValidationCss();");

            rdoYesCarRentalExtension.Attributes.Add("onblur", "CheckCarRentalExtensionValidationCss()");
            rdoNoCarRentalExtension.Attributes.Add("onblur", "CheckCarRentalExtensionValidationCss()");
            rdoYesNCDProtector.Attributes.Add("onblur", "CheckNCDProtectorValidationCss()");
            rdoNoNCDProtector.Attributes.Add("onblur", "CheckNCDProtectorValidationCss()");
            rdoYesDealerWorkshopExtension.Attributes.Add("onblur", "CheckDealerWorkshopExtensionValidationCss()");
            rdoNoDealerWorkshopExtension.Attributes.Add("onblur", "CheckDealerWorkshopExtensionValidationCss()");
            rdoYesSunRoofExtension.Attributes.Add("onblur", "CheckSunRoofExtensionValidationCss()");
            rdoNoSunRoofExtension.Attributes.Add("onblur", "CheckSunRoofExtensionValidationCss()");
            rdoYesMoonRoofExtension.Attributes.Add("onblur", "CheckMoonRoofExtensionValidationCss()");
            rdoNoMoonRoofExtension.Attributes.Add("onblur", "CheckMoonRoofExtensionValidationCss()");

            rdoYesPurposeofuse.Attributes.Add("onblur", "CheckPurposeofuseValidationCss();");
            rdoNoPurposeofuse.Attributes.Add("onblur", "CheckPurposeofuseValidationCss();");
            rdoYesPhysicalinfirm.Attributes.Add("onblur", "CheckPhysicalinfirmValidationCss();");
            rdoNoPhysicalinfirm.Attributes.Add("onblur", "CheckPhysicalinfirmValidationCss();");
            rdoYesAccident.Attributes.Add("onblur", "CheckAccidentValidationCss();");
            rdoNoAccident.Attributes.Add("onblur", "CheckAccidentValidationCss();");
            rdoYesTraffic.Attributes.Add("onblur", "CheckTrafficValidationCss();");
            rdoNoTraffic.Attributes.Add("onblur", "CheckTrafficValidationCss();");
            rdoYesInsuranceterminated.Attributes.Add("onblur", "CheckInsuranceterminatedValidationCss();");
            rdoNoInsuranceterminated.Attributes.Add("onblur", "CheckInsuranceterminatedValidationCss();");
            rdoYesDermeritPoints.Attributes.Add("onblur", "CheckDermeritPointsValidationCss();");
            rdoNoDermeritPoints.Attributes.Add("onblur", "CheckDermeritPointsValidationCss();");
            //rdoYesExistingInsurer.Attributes.Add("onblur", "CheckExistingInsurerValidationCss();");
            //rdoNoExistingInsurer.Attributes.Add("onblur", "CheckExistingInsurerValidationCss();");
            rdoVisa.Attributes.Add("onblur", "CheckCardTypeValidationCss();");
            rdoMasterCard.Attributes.Add("onblur", "CheckCardTypeValidationCss();");

            rdoNew.Attributes.Add("onblur", "CheckVehicleStatusValidationCss();");
            rdoUsed.Attributes.Add("onblur", "CheckVehicleStatusValidationCss();");
            rdoYesPolicyRDCOpted.Attributes.Add("onblur", "CheckPolicyRDCOptedValidationCss();");
            rdoNoPolicyRDCOpted.Attributes.Add("onblur", "CheckPolicyRDCOptedValidationCss();");

            //rdoYesCarRentalExtension.Attributes.Add("onclick", "SetPremium()");
            //rdoYesNCDProtector.Attributes.Add("onclick", "SetPremium()");
            #endregion

            #region Set Property
            if (Session[CE.Global.General.UserPhoneNo] != null)
            {
                txtMobileNo.PhoneNo = Session[CE.Global.General.UserPhoneNo].ToString();
            }
            if (Session[CE.Global.General.UserName] != null)
            {
                txtName.Text = Session[CE.Global.General.UserName].ToString().Trim();
            }
            LoadCarPolicyDetails();
            
            #endregion

            Session[General.ViewedDetailsId] = LogUserViewedHistory().ToString();
        }

        if (rdoYesHirePurchase.Checked || rdoNoHirePurchase.Checked) txtHirePurchase.Text = "1";
        if (rdoYesDrivingWestMalaysia.Checked || rdoNoDrivingWestMalaysia.Checked) txtDrivingWestMalaysia.Text = "1";
        if (rdoYesVechicleModification.Checked || rdoNoVechicleModification.Checked) txtVechicleModification.Text = "1";
        if (rdoYesCOE.Checked || rdoNoCOE.Checked) txtMarketvalue.Text = "1";
        if (rdoYesPurposeofuse.Checked || rdoNoPurposeofuse.Checked) txtPurposeofuse.Text = "1";
        if (rdoYesPhysicalinfirm.Checked || rdoNoPhysicalinfirm.Checked) txtPhysicalinfirm.Text = "1";
        if (rdoYesAccident.Checked || rdoYesAccident.Checked) txtAccident.Text = "1";
        if (rdoYesTraffic.Checked || rdoYesTraffic.Checked) txtTraffic.Text = "1";
        if (rdoYesInsuranceterminated.Checked || rdoNoInsuranceterminated.Checked) txtInsuranceterminated.Text = "1";
        if (rdoYesDermeritPoints.Checked || rdoNoDermeritPoints.Checked) txtDermeritPoints.Text = "1";
        //if (rdoYesExistingInsurer.Checked || rdoNoExistingInsurer.Checked) txtExistingInsurer.Text = "1";
        if (rdoVisa.Checked || rdoMasterCard.Checked) txtCardType.Text = "1";
        if (rdoNew.Checked || rdoUsed.Checked) txtVehicleStatus.Text = "1";
        if (rdoYesPolicyRDCOpted.Checked || rdoNoPolicyRDCOpted.Checked) txtPolicyRDCOpted.Text = "1";

    }

    private Int64 LogUserViewedHistory()
    {
        UserViewHistoryDB _userviewdb = new UserViewHistoryDB();
        return _userviewdb.LogViewedHistory("CI", Request, "Car Insurance RSA proposal form.");
    }

    protected void txtPostCode_TextChanged(object sender, EventArgs e)
    {
        rfvPostCode.Validate();
        revPostCode.Validate();
        if (rfvPostCode.IsValid && revPostCode.IsValid)
        {
            txtPostCode.ControlStyle.CssClass = "";
            txtAddress.ControlStyle.CssClass = "";
            MyLocation _myLoc = new MyLocation();
            System.Data.DataSet _ds = _myLoc.GetAddressByPostCodeDataSet(txtPostCode.Text);
            ddlAddressList.Items.Clear();
            string _lstValue;
            string _lstText;
            int _rowCount = 0;

            if (_ds != null && _ds.Tables.Count > 0)
            {
                foreach (System.Data.DataTable _dt in _ds.Tables)
                {
                    if (_dt.Rows.Count > 0)
                    {
                        foreach (System.Data.DataRow _dr in _dt.Rows)
                        {
                            _lstValue = _dr["t"].ToString() + ", " + _dr["a"].ToString();
                            _lstText = _dr["t"].ToString();
                            ddlAddressList.Items.Add(new ListItem(_lstText, _lstValue));
                            if (_rowCount == 0)
                            {
                                txtAddress.Text = _lstValue;
                                txtAddress.ReadOnly = true;
                            }
                            _rowCount++;
                        }
                    }
                    else
                    {
                        txtAddress.Text = "No address found.";
                        txtAddress.ReadOnly = false;
                        txtAddress.ControlStyle.CssClass = "validationError";
                    }
                }
            }
            else
            {
                txtAddress.Text = "No address found.";
                txtAddress.ReadOnly = false;
                txtAddress.ControlStyle.CssClass = "validationError";
            }

            if (_rowCount > 1)
            {
                divAddressList.Visible = true;
            }
            else
            {
                divAddressList.Visible = false;
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "validationError";
            ddlAddressList.Items.Clear();
            divAddressList.Visible = false;
            txtAddress.Text = "Invalid postcode.";
            txtAddress.ControlStyle.CssClass = "validationError";
        }
    }

    protected void ddlAddressList_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlAddressList.Items.Count > 0 && ddlAddressList.SelectedIndex >= 0)
        {
            txtAddress.Text = ddlAddressList.Text;
        }
    }

    protected void btnPostCode_Click(object sender, EventArgs e)
    {
        txtPostCode_TextChanged(sender, e);
    }

    protected void csvCreditCardValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        bool _status = true;
        string _first = txtCardNo1.Text.Trim().Substring(0, 1);
        if (rdoVisa.Checked)
        {
            if (_first != "4")
            {
                _status = false;
            }
        }
        else if (rdoMasterCard.Checked)
        {
            if (_first != "5")
            {
                _status = false;
            }
        }
        if (_status == true)
        {
            txtCreditCardValid.Text = "";
            txtCreditCardValid.Text = txtCardNo1.Text.Trim() + "" + txtCardNo2.Text.Trim() + "" + txtCardNo3.Text.Trim() + "" + txtCardNo4.Text.Trim();
            string _cardNumer = txtCreditCardValid.Text;
            MySecurity _mysecurity = new MySecurity();
            if (_mysecurity.IsCreditCardValid(_cardNumer))
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = false;
        }
    }

    protected void csvCCExpiredValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        txtCCExpiredValid.Text = "";
        txtCCExpiredValid.Text = "valid";
        Int32 _Year = Convert.ToInt32(ddlCardExpiryYear.Text);
        Int32 _Month = Convert.ToInt32(ddlCardExpiryMonth.Text);

        MySecurity _mysecurity = new MySecurity();
        if (_mysecurity.IsCreditCardExpiredDateValid(_Year, _Month))
        {
            args.IsValid = true;
        }
        else
        {
            args.IsValid = false;
        }
    }

    protected void ibtSubmit_Click(object sender, ImageClickEventArgs e)
    {
        CheckValidation();
        ChangeValidationEffectServerSide("proposal");
        if (IsValid)
        {
            Int64 _carmoreresult = 0;
            Int64 demeritresult = 0;
            Int64 driverresult = 0;
            RsaCarMoreDetail _rsacarmoredetail = new RsaCarMoreDetail();
            RsaCarMoreDetailDB _rsacarmoredetaildb = new RsaCarMoreDetailDB();

            if (Session[General.CarMoreDetailId] != null)
            {
                _rsacarmoredetail.CECarMoreDetailId = Convert.ToInt64(Session[General.CarMoreDetailId].ToString());
            }
            else
            {
                _rsacarmoredetail.CECarMoreDetailId = 0;
            }

            _rsacarmoredetail.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
            _rsacarmoredetail.ProviderCompanyId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
            _rsacarmoredetail.Salutation = ddlSalutation.GetSalutation(); //S
            _rsacarmoredetail.Name = txtName.Text.ToUpper();
            _rsacarmoredetail.NRICNo = ddlIdNumber.GetIdNumber();
            _rsacarmoredetail.Nationality = ddlNationality.GetNationality();
            _rsacarmoredetail.PostalCode = txtPostCode.Text.Trim();
            _rsacarmoredetail.UnitNo = txtUnit1.Text.Trim();
            _rsacarmoredetail.HomeNo = txtUnit2.Text.Trim();
            _rsacarmoredetail.Address = txtAddress.Text.Trim();
            _rsacarmoredetail.MobileNo = txtMobileNo.GetPhoneNo();
            _rsacarmoredetail.HomePhoneNo = txtResidentialPhoneNo.GetPhoneNo();
            _rsacarmoredetail.OfficePhoneNo = txtOfficePhoneNo.GetPhoneNo();
            _rsacarmoredetail.FaxNo = txtFaxNo.GetPhoneNo();           
            _rsacarmoredetail.DriveExpYear = Convert.ToInt32(ddlExperienceYear.Text);
            _rsacarmoredetail.DriveExpMonth = Convert.ToInt32(ddlExperienceMonth.Text);
            _rsacarmoredetail.DrivingLicenceNo = txtDrivingLicenceNo.Text;
            _rsacarmoredetail.DrivingClass = txtDrivingClass.Text;
            _rsacarmoredetail.YearObtained = Convert.ToInt32(ddlYearObtained.Text);
            _rsacarmoredetail.IsNewVehicle = rdoNew.Checked; //S
            _rsacarmoredetail.VechicleNo = txtVehicleNo.Text;
            _rsacarmoredetail.EngineNo = txtEngineNo.Text;
            _rsacarmoredetail.ChassisNo = txtChassisNo.Text;
            _rsacarmoredetail.VehicleTransmission = ddlVehicleTransmission.Text; //S
            _rsacarmoredetail.VehiclePropellant = ddlVehiclePropellant.Text; //S
            if (txtVehicleSumInsured.Text.Trim() != "")
            {
                _rsacarmoredetail.VehicleSumInsured = Convert.ToSingle(txtVehicleSumInsured.Text); //S
            }
            else
            {
                _rsacarmoredetail.VehicleSumInsured = 0;
            }
            if (txtClaimODAmount.Text.Trim() != "")
            {
                _rsacarmoredetail.ClaimODAmount = Convert.ToSingle(txtClaimODAmount.Text); //S
            }
            else
            {
                _rsacarmoredetail.ClaimODAmount = 0;
            }
            if (txtClaimTPPDAmount.Text.Trim() != "")
            {
                _rsacarmoredetail.ClaimTPPDAmount = Convert.ToSingle(txtClaimTPPDAmount.Text); //S
            }
            else
            {
                _rsacarmoredetail.ClaimTPPDAmount = 0;
            }
            _rsacarmoredetail.IsPolicyRDCOpted = rdoYesPolicyRDCOpted.Checked; //S
            _rsacarmoredetail.HasHirePurchase = rdoYesHirePurchase.Checked;
            _rsacarmoredetail.HPCompanyName = ddlHirePurchaseCompany.Text;
            _rsacarmoredetail.HasDriveWestMalaysia = rdoYesDrivingWestMalaysia.Checked;
            _rsacarmoredetail.HowOften = ddlDrivetowestmalaysia.Text;
            _rsacarmoredetail.Aircon = chkAircon.Checked;
            _rsacarmoredetail.Radio = chkRadio.Checked;
            _rsacarmoredetail.SportsRims = chkSports.Checked;
            _rsacarmoredetail.SunRoof = chkSunroof.Checked;
            _rsacarmoredetail.MoonRoof = chkMoonroof.Checked;
            _rsacarmoredetail.OtherAccessories = txtOtherAccessories.Text.Trim();
            _rsacarmoredetail.HasVechicleModified = rdoYesVechicleModification.Checked;
            _rsacarmoredetail.VechicleModifyReason = txtVMReason.Text.Trim();
            _rsacarmoredetail.HasCOE = rdoYesCOE.Checked;
            _rsacarmoredetail.CarRentalExten = rdoYesCarRentalExtension.Checked;
            _rsacarmoredetail.NCDProtectorExten = rdoYesNCDProtector.Checked;
            _rsacarmoredetail.DealerWorkShopExten = rdoYesDealerWorkshopExtension.Checked;
            _rsacarmoredetail.SunRoofExten = rdoYesSunRoofExtension.Checked;
            if (rdoYesSunRoofExtension.Checked)
            {
                _rsacarmoredetail.SunRoofAmount = Convert.ToSingle(txtSunroofExtenAmt.Text);
            }
            else
            {
                _rsacarmoredetail.SunRoofAmount = 0;
            }
            _rsacarmoredetail.MoonRoofExten = rdoYesMoonRoofExtension.Checked;
            if (rdoYesMoonRoofExtension.Checked)
            {
                _rsacarmoredetail.MoonRoofAmount = Convert.ToSingle(txtMoonroofExtenAmt.Text);
            }
            else
            {
                _rsacarmoredetail.MoonRoofAmount = 0;
            }
            _rsacarmoredetail.OtherExtension = txtOtherExtension.Text.Trim();
            _rsacarmoredetail.SocialUse = rdoYesPurposeofuse.Checked;
            _rsacarmoredetail.HasPhysicalImpairmty = rdoYesPhysicalinfirm.Checked;
            _rsacarmoredetail.PhysicalImpairmtyReason = txtPIReason.Text.Trim();
            _rsacarmoredetail.HasAccidentInvolved = rdoYesAccident.Checked;
            _rsacarmoredetail.AccidentInvolvedReason = txtAIReason.Text.Trim();
            _rsacarmoredetail.HasTrafficConvicted = rdoYesTraffic.Checked;
            _rsacarmoredetail.TrafficConvictedReason = txtTCReason.Text.Trim();
            _rsacarmoredetail.HasInsuranceTerminated = rdoYesInsuranceterminated.Checked;
            _rsacarmoredetail.InsuranceTerminatedReason = txtITReason.Text.Trim();
            _rsacarmoredetail.HasDemeritPoints = rdoYesDermeritPoints.Checked;
            _rsacarmoredetail.HasPreInsurer = true; // rdoYesExistingInsurer.Checked;
            _rsacarmoredetail.PreInsurerName = ddlExistingInsurerName.Text;
            _rsacarmoredetail.PreInsVechicleNo = txtInsRegisterNo.Text.Trim();
            _rsacarmoredetail.PreInsNCD = Convert.ToInt32(ddlExistNCD.Text);
            _rsacarmoredetail.PreInsPolicyNo = txtInsPolicyNo.Text.Trim();

            if (ddlDOCancellation.GetDate().ToString("ddmmyyyy") == "01000001")
            {
                _rsacarmoredetail.PreInsExpiryDate = Convert.ToDateTime("01/01/1900");
            }
            else
            {
                _rsacarmoredetail.PreInsExpiryDate = ddlDOCancellation.GetDate();
            }

            
            //_rsacarmoredetail.NameoftheCard = txtNameoftheCard.Text.Trim();
            //_rsacarmoredetail.IssuingBankName = txtIssuingBank.Text.Trim();
            //_rsacarmoredetail.CreditCardNo = txtCardNo1.Text.Trim() + "" + txtCardNo2.Text.Trim() + "" + txtCardNo3.Text.Trim() + "" + txtCardNo4.Text.Trim();
            //_rsacarmoredetail.CardExpiryMonth = ddlCardExpiryMonth.Text;
            //_rsacarmoredetail.CardExpiryYear = ddlCardExpiryYear.Text;
            _rsacarmoredetail.PamentType = "CreditCard";
           
            _rsacarmoredetail.QuoteRefNo = lblQRefNo.Text.Trim();

            _rsacarmoredetail.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _rsacarmoredetail.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _rsacarmoredetail.Status = true;
            _rsacarmoredetail.CarResultId = Convert.ToInt64(Session[General.CarResultId].ToString());

            _carmoreresult = _rsacarmoredetaildb.Insert(_rsacarmoredetail);
            if (_carmoreresult > 0)
            {
                Int64 _paymentresult = 0;
                Payment _payment = new Payment();
                PaymentDB _paymentdb = new PaymentDB();

                _payment.CXPaymentId = 0;
                _payment.RefId = Convert.ToInt64(Session[General.CarId].ToString());
                _payment.ProviderCompanyId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
                _payment.InsuranceType = "CI";
                _payment.NameoftheCard = txtNameoftheCard.Text.ToUpper();
                _payment.IssuingBankName = txtIssuingBank.Text.Trim();
                _payment.CreditCardNo = txtCardNo1.Text.Trim() + "" + txtCardNo2.Text.Trim() + "" + txtCardNo3.Text.Trim() + "" + txtCardNo4.Text.Trim();
                _payment.CardExpiryMonth = ddlCardExpiryMonth.Text;
                _payment.CardExpiryYear = ddlCardExpiryYear.Text;
                if (rdoVisa.Checked == true)
                {
                    _payment.CardType = "Visa";
                }
                else
                {
                    _payment.CardType = "MasterCard";
                }
                _payment.Status = true;
                if (Session[CE.Global.General.UserId] != null)
                {
                    _payment.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
                }
                else
                {
                    _payment.RefCEUserId = 0;
                }
                _paymentresult = _paymentdb.Insert(_payment);


                if (_paymentresult > 0)
                {
                    Session[CE.Global.General.CarMoreDetailId] = _carmoreresult.ToString();
                    if (rdoYesDermeritPoints.Checked == true)
                    {
                        Int64 CarId = Convert.ToInt64(Session[General.CarId].ToString());
                        Int64 CEId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
                        CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
                        _cardriverdemeritpointsdb.DeleteCarDriverDemeritPoints(CarId, _carmoreresult, CEId);
                        _cardriverdemeritpointsdb = null;

                        if (!SaveDemeritPoints())
                        {
                            lblMessage.Text = "Demerit Points failed to save!";
                        }
                        else
                        {
                            demeritresult = 1;
                        }
                    }
                    else
                    {
                        demeritresult = 1;
                    }
                    if (demeritresult > 0)
                    {
                        if (txtDriverCount.Text.Trim() != "0")
                        {
                            if (!UpdateDriverDetails())
                            {
                                lblMessage.Text = "Car Drivers failed to save!";
                            }
                            else
                            {
                                driverresult = 1;
                            }
                        }
                        else
                        {
                            driverresult = 1;
                        }
                        if (driverresult > 0)
                        {
                            Int64 _statusresult = 0;
                            _rsacarmoredetail.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
                            _rsacarmoredetail.CarResultId = Convert.ToInt64(Session[General.CarResultId].ToString());

                            _statusresult = _rsacarmoredetaildb.UpdateStatus(_rsacarmoredetail);

                            Session[CE.Global.General.CarMoreDetailId] = _carmoreresult.ToString();
                            UserConfirmation _userconfirm = new UserConfirmation();
                            UserConfirmationDB _userconfirmdb = new UserConfirmationDB();
                            _userconfirm.ConfirmationType = "CI";
                            _userconfirm.CurrentStep = 4;
                            //_userconfirm.UserResultId = Convert.ToInt64(Session[General.CarResultId].ToString());
                            _userconfirm.UserSelectedId = Convert.ToInt64(Session[General.CarResultId].ToString());
                            _userconfirm.FirstStepId = Convert.ToInt64(Session[General.CarId].ToString());
                            _userconfirm.RefCEUserId = Convert.ToInt64(Session[General.UserId].ToString());
                            _userconfirm.IsConfirm = true;
                            _userconfirm.ResultStatus = "Complete";
                            _userconfirm.IsComplete = true;
                            Int64 _result = _userconfirmdb.Insert(_userconfirm);

                            //if ((_result > 0) && (_statusresult > 0))
                            //{
                            //    //GenerateExcelProposalForm(Convert.ToInt64(Session[CE.Global.General.CarId]));
                            //    //GeneratePDFProposalForm(Convert.ToInt64(Session[CE.Global.General.CarId]));
                            ProposalNotification();
                            string _provideid = Encode(Session[General.ProviderCompanyId].ToString());
                            string _refid = "";
                            string convertno = General.GetRefNumber(Convert.ToInt64(Session[CE.Global.General.CarId]));
                            _refid = "R" + convertno;

                            General.ClearAllSession(this.Page, "ALL");
                            Response.Redirect("~/car-insurance/usermessage.aspx?pcid=" + _provideid + "&ref=" + _refid);
                            
                            //}
                            //else
                            //{
                            //    lblMessage.Text = "Can't update confirmation status.";
                            //}
                        }
                    }
                }
            }
        }
    }

    protected void ibtnBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/car-insurance/results.aspx?sortby=0");
    }

    public void LoadCarPolicyDetails()
    {
        _CarId = Convert.ToInt64(Session[General.CarId].ToString());
        _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
        _CXCTypeId = Convert.ToInt64(Session[CE.Global.General.CarResultId].ToString());
        _ProviderId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
        //DataTable _dtProvider = new DataTable();
        DataSet _dtProvider = new DataSet();
        RsaCarMoreDetailDB _rsacarmoredetaildb = new RsaCarMoreDetailDB();

        _dtProvider = _rsacarmoredetaildb.GetCarPolicyDetails(_CarId, _UserId, _CXCTypeId, _ProviderId);
        if (_dtProvider != null)
        {
            lblYrofManufacture.Text = _dtProvider.Tables[0].Rows[0]["ManufactYear"].ToString();
            lblYrofRegister.Text = _dtProvider.Tables[0].Rows[0]["RegYear"].ToString();
            lblCarMakemodel.Text = _dtProvider.Tables[0].Rows[0]["MakeModelDesc"].ToString();
            lblOffpeakvehile.Text = _dtProvider.Tables[0].Rows[0]["Offbeak"].ToString();
            if (_dtProvider.Tables[0].Rows[0]["NCDPercent"].ToString() == "-1")
            {
                lblNCDvalue.Text = "No NCD (First Policy)";
            }
            else
            {
                lblNCDvalue.Text = _dtProvider.Tables[0].Rows[0]["NCDPercent"].ToString() + "%";
            }
            inputNCD.Value = _dtProvider.Tables[0].Rows[0]["AppNCD"].ToString();
            lblNCDRenewal.Text = _dtProvider.Tables[0].Rows[0]["AppNCD"].ToString() + "%";

            lblAnyclaim.Text = _dtProvider.Tables[0].Rows[0]["Claim"].ToString();
            inputClaim.Value = _dtProvider.Tables[0].Rows[0]["Claim"].ToString();
            //Response.Write(inputClaim.Value);
            lblOffenceDriving.Text = _dtProvider.Tables[0].Rows[0]["OffDriveCom"].ToString();
            if (_dtProvider.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
            {
                lblAddDriver.Text = _dtProvider.Tables[0].Rows[0]["NoOfDriver"].ToString();
                txtDriverCount.Text = _dtProvider.Tables[0].Rows[0]["NoOfDriver"].ToString();
            }
            else
            {
                lblAddDriver.Text = _dtProvider.Tables[0].Rows[0]["AddDriver"].ToString();
                txtDriverCount.Text = "0";
            }
            EnableDriverPanels();
            lblCommencementdate.Text = _dtProvider.Tables[0].Rows[0]["CommenceDate"].ToString();
            lblSelectInsurer.Text = _dtProvider.Tables[1].Rows[0]["CompanyName"].ToString();
            lblPremiums.Text = "$" + _dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString();
            lblWorkshopPlan.Text = _dtProvider.Tables[1].Rows[0]["PlanName"].ToString();

            lblExistingPremium.Text = "$" + _dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString();
            lblNewPremium1.Text = "$" + (float.Parse(_dtProvider.Tables[1].Rows[0]["PremiumWithNCDProtect"].ToString()) + 107).ToString();
            lblNewPremium2.Text = "$" + (float.Parse(_dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString()) + 107).ToString();
            lblNewPremium3.Text = "$" + _dtProvider.Tables[1].Rows[0]["PremiumWithNCDProtect"].ToString();

            string convertno = General.GetRefNumber(_CarId);
            if (_ProviderId == 23)
            {
                lblQRefNo.Text = "H" + convertno.ToString(); // +"_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;
            }
            else if (_ProviderId == 29)
            {
                lblQRefNo.Text = "L" + convertno.ToString();
            }
            else if (_ProviderId == 30)
            {
                lblQRefNo.Text = "E" + convertno.ToString();
            }
            else if (_ProviderId == 24)
            {
                lblQRefNo.Text = "R" + convertno.ToString();
            }
            
            ddlExperienceYear.Items.Insert(0, new ListItem(_dtProvider.Tables[2].Rows[0]["YearDriveSg"].ToString(), _dtProvider.Tables[2].Rows[0]["YearDriveSg"].ToString()));
            ddlExistingInsurerName.Text = _dtProvider.Tables[0].Rows[0]["Info1"].ToString();
        }
        LoadCarDrivers();
    }

    private void LoadCarDrivers()
    {
        CarDriverDB _cardriverdb = new CarDriverDB();
        _CarId = Convert.ToInt64(Session[General.CarId].ToString());
        _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
        DataTable _driverList = _cardriverdb.GetDriverList(_CarId, _UserId);
        if (_driverList.Rows.Count > 0)
        {
            lblDriverId1.Text = _driverList.Rows[0]["CarDriverId"].ToString();

            _dtDOB1 = Convert.ToDateTime(_driverList.Rows[0]["DOB"].ToString());
            lblDriverDOB1.Text = _dtDOB1.Day.ToString("00") + "/" + _dtDOB1.Month.ToString("00") + "/" + _dtDOB1.Year.ToString("0000");
            if (_driverList.Rows[0]["Gender"].ToString() == "M")
            {
                lblDriverGender1.Text = "Male";
            }
            else if (_driverList.Rows[0]["Gender"].ToString() == "F")
            {
                lblDriverGender1.Text = "Female";
            }
            if (_driverList.Rows[0]["Surname"].ToString() != null && _driverList.Rows[0]["Surname"].ToString() != "")
            {
                txtDriverName1.Text = _driverList.Rows[0]["Surname"].ToString();
            }
            ddlDriverExperienceYear1.Items.Insert(0, new ListItem(_driverList.Rows[0]["YearOfDrivingInSg"].ToString(), _driverList.Rows[0]["YearOfDrivingInSg"].ToString()));
        }
        if (_driverList.Rows.Count > 1)
        {
            lblDriverId2.Text = _driverList.Rows[1]["CarDriverId"].ToString();

            _dtDOB2 = Convert.ToDateTime(_driverList.Rows[1]["DOB"].ToString());
            lblDriverDOB2.Text = _dtDOB2.Day.ToString("00") + "/" + _dtDOB2.Month.ToString("00") + "/" + _dtDOB2.Year.ToString("0000");
            if (_driverList.Rows[1]["Gender"].ToString() == "M")
            {
                lblDriverGender2.Text = "Male";
            }
            else if (_driverList.Rows[1]["Gender"].ToString() == "F")
            {
                lblDriverGender2.Text = "Female";
            }
            if (_driverList.Rows[1]["Surname"].ToString() != null && _driverList.Rows[1]["Surname"].ToString() != "")
            {
                txtDriverName2.Text = _driverList.Rows[1]["Surname"].ToString();
            }
            ddlDriverExperienceYear2.Items.Insert(0, new ListItem(_driverList.Rows[1]["YearOfDrivingInSg"].ToString(), _driverList.Rows[1]["YearOfDrivingInSg"].ToString()));
        }
        if (_driverList.Rows.Count > 2)
        {
            lblDriverId3.Text = _driverList.Rows[2]["CarDriverId"].ToString();

            _dtDOB3 = Convert.ToDateTime(_driverList.Rows[2]["DOB"].ToString());
            lblDriverDOB3.Text = _dtDOB3.Day.ToString("00") + "/" + _dtDOB3.Month.ToString("00") + "/" + _dtDOB3.Year.ToString("0000");
            if (_driverList.Rows[2]["Gender"].ToString() == "M")
            {
                lblDriverGender3.Text = "Male";
            }
            else if (_driverList.Rows[2]["Gender"].ToString() == "F")
            {
                lblDriverGender3.Text = "Female";
            }
            if (_driverList.Rows[2]["Surname"].ToString() != null && _driverList.Rows[2]["Surname"].ToString() != "")
            {
                txtDriverName3.Text = _driverList.Rows[2]["Surname"].ToString();
            }
            ddlDriverExperienceYear3.Items.Insert(0, new ListItem(_driverList.Rows[2]["YearOfDrivingInSg"].ToString(), _driverList.Rows[2]["YearOfDrivingInSg"].ToString()));
        }
        if (_driverList.Rows.Count > 3)
        {
            lblDriverId4.Text = _driverList.Rows[3]["CarDriverId"].ToString();

            _dtDOB4 = Convert.ToDateTime(_driverList.Rows[3]["DOB"].ToString());
            lblDriverDOB4.Text = _dtDOB4.Day.ToString("00") + "/" + _dtDOB4.Month.ToString("00") + "/" + _dtDOB4.Year.ToString("0000");
            if (_driverList.Rows[3]["Gender"].ToString() == "M")
            {
                lblDriverGender4.Text = "Male";
            }
            else if (_driverList.Rows[3]["Gender"].ToString() == "F")
            {
                lblDriverGender4.Text = "Female";
            }
            if (_driverList.Rows[3]["Surname"].ToString() != null && _driverList.Rows[3]["Surname"].ToString() != "")
            {
                txtDriverName4.Text = _driverList.Rows[3]["Surname"].ToString();
            }
            ddlDriverExperienceYear4.Items.Insert(0, new ListItem(_driverList.Rows[3]["YearOfDrivingInSg"].ToString(), _driverList.Rows[3]["YearOfDrivingInSg"].ToString()));
        }
        if (_driverList.Rows.Count > 4)
        {
            lblDriverId5.Text = _driverList.Rows[4]["CarDriverId"].ToString();

            _dtDOB5 = Convert.ToDateTime(_driverList.Rows[4]["DOB"].ToString());
            lblDriverDOB5.Text = _dtDOB5.Day.ToString("00") + "/" + _dtDOB5.Month.ToString("00") + "/" + _dtDOB5.Year.ToString("0000");
            if (_driverList.Rows[4]["Gender"].ToString() == "M")
            {
                lblDriverGender5.Text = "Male";
            }
            else if (_driverList.Rows[4]["Gender"].ToString() == "F")
            {
                lblDriverGender5.Text = "Female";
            }
            if (_driverList.Rows[4]["Surname"].ToString() != null && _driverList.Rows[4]["Surname"].ToString() != "")
            {
                txtDriverName5.Text = _driverList.Rows[4]["Surname"].ToString();
            }
            ddlDriverExperienceYear5.Items.Insert(0, new ListItem(_driverList.Rows[4]["YearOfDrivingInSg"].ToString(), _driverList.Rows[4]["YearOfDrivingInSg"].ToString()));
        }
    }

    private void EnableDriverPanels()
    {
        if (txtDriverCount.Text.Trim() == "0")
        {
            pnlDriverDetails.Visible = false;
            pnlDriver1.Visible = false;
            pnlDriver2.Visible = false;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(false);
            ValidateDriver2(false);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "1")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = false;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(false);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "2")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "3")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "4")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = true;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(true);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "5")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = true;
            pnlDriver5.Visible = true;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(true);
            ValidateDriver5(true);
        }
    }

    private void ValidateDriver1(bool OnOff)
    {
        rfvDriverName1.Enabled = OnOff;
        ddlDriverRelation1.IsEnableValidation(OnOff);
        rfvDriverDrivingClass1.Enabled = OnOff;
        rfvDriverYearObtained1.Enabled = OnOff;
    }

    private void ValidateDriver2(bool OnOff)
    {
        rfvDriverName2.Enabled = OnOff;
        ddlDriverRelation2.IsEnableValidation(OnOff);
        rfvDriverDrivingClass2.Enabled = OnOff;
        rfvDriverYearObtained2.Enabled = OnOff;
    }

    private void ValidateDriver3(bool OnOff)
    {
        rfvDriverName3.Enabled = OnOff;
        ddlDriverRelation3.IsEnableValidation(OnOff);
        rfvDriverDrivingClass3.Enabled = OnOff;
        rfvDriverYearObtained3.Enabled = OnOff;
    }

    private void ValidateDriver4(bool OnOff)
    {
        rfvDriverName4.Enabled = OnOff;
        ddlDriverRelation4.IsEnableValidation(OnOff);
        rfvDriverDrivingClass4.Enabled = OnOff;
        rfvDriverYearObtained4.Enabled = OnOff;
    }

    private void ValidateDriver5(bool OnOff)
    {
        rfvDriverName5.Enabled = OnOff;
        ddlDriverRelation5.IsEnableValidation(OnOff);
        rfvDriverDrivingClass5.Enabled = OnOff;
        rfvDriverYearObtained5.Enabled = OnOff;
    }

    private void CheckValidation()
    {
        txtName.Text = General.ClearScriptTag(txtName.Text);
        txtPostCode.Text = General.ClearScriptTag(txtPostCode.Text);
        txtUnit1.Text = General.ClearScriptTag(txtUnit1.Text);
        txtUnit2.Text = General.ClearScriptTag(txtUnit2.Text);
        txtAddress.Text = General.ClearScriptTag(txtAddress.Text);
        txtDrivingLicenceNo.Text = General.ClearScriptTag(txtDrivingLicenceNo.Text);
        txtDrivingClass.Text = General.ClearScriptTag(txtDrivingClass.Text);

        txtVehicleNo.Text = General.ClearScriptTag(txtVehicleNo.Text);
        txtEngineNo.Text = General.ClearScriptTag(txtEngineNo.Text);
        txtChassisNo.Text = General.ClearScriptTag(txtChassisNo.Text);
        txtVMReason.Text = General.ClearScriptTag(txtVMReason.Text);
        txtSunroofExtenAmt.Text = General.ClearScriptTag(txtSunroofExtenAmt.Text);
        txtMoonroofExtenAmt.Text = General.ClearScriptTag(txtMoonroofExtenAmt.Text);

        txtPIReason.Text = General.ClearScriptTag(txtPIReason.Text);
        txtAIReason.Text = General.ClearScriptTag(txtAIReason.Text);
        txtTCReason.Text = General.ClearScriptTag(txtTCReason.Text);
        txtITReason.Text = General.ClearScriptTag(txtITReason.Text);
        txtInsRegisterNo.Text = General.ClearScriptTag(txtInsRegisterNo.Text);
        txtInsPolicyNo.Text = General.ClearScriptTag(txtInsPolicyNo.Text);

        txtDriverName1.Text = General.ClearScriptTag(txtDriverName1.Text);
        txtDriverDrivingClass1.Text = General.ClearScriptTag(txtDriverDrivingClass1.Text);
        txtDriverName2.Text = General.ClearScriptTag(txtDriverName2.Text);
        txtDriverDrivingClass2.Text = General.ClearScriptTag(txtDriverDrivingClass2.Text);
        txtDriverName3.Text = General.ClearScriptTag(txtDriverName3.Text);
        txtDriverDrivingClass3.Text = General.ClearScriptTag(txtDriverDrivingClass3.Text);
        txtDriverName4.Text = General.ClearScriptTag(txtDriverName4.Text);
        txtDriverDrivingClass4.Text = General.ClearScriptTag(txtDriverDrivingClass4.Text);
        txtDriverName5.Text = General.ClearScriptTag(txtDriverName5.Text);
        txtDriverDrivingClass5.Text = General.ClearScriptTag(txtDriverDrivingClass5.Text);

        txtNameoftheCard.Text = General.ClearScriptTag(txtNameoftheCard.Text);
        txtIssuingBank.Text = General.ClearScriptTag(txtIssuingBank.Text);
        txtCardNo1.Text = General.ClearScriptTag(txtCardNo1.Text);
        txtCardNo2.Text = General.ClearScriptTag(txtCardNo2.Text);
        txtCardNo3.Text = General.ClearScriptTag(txtCardNo3.Text);
        txtCardNo4.Text = General.ClearScriptTag(txtCardNo4.Text);

        txtDemeritDrivername1.Text = General.ClearScriptTag(txtDemeritDrivername1.Text);
        txtTotalpoints1.Text = General.ClearScriptTag(txtTotalpoints1.Text);
        txtOffencetype1.Text = General.ClearScriptTag(txtOffencetype1.Text);

        txtDemeritDrivername2.Text = General.ClearScriptTag(txtDemeritDrivername2.Text);
        txtTotalpoints2.Text = General.ClearScriptTag(txtTotalpoints2.Text);
        txtOffencetype2.Text = General.ClearScriptTag(txtOffencetype2.Text);

        txtDemeritDrivername3.Text = General.ClearScriptTag(txtDemeritDrivername3.Text);
        txtTotalpoints3.Text = General.ClearScriptTag(txtTotalpoints3.Text);
        txtOffencetype3.Text = General.ClearScriptTag(txtOffencetype3.Text);

        txtDemeritDrivername4.Text = General.ClearScriptTag(txtDemeritDrivername4.Text);
        txtTotalpoints4.Text = General.ClearScriptTag(txtTotalpoints4.Text);
        txtOffencetype4.Text = General.ClearScriptTag(txtOffencetype4.Text);

        txtDemeritDrivername5.Text = General.ClearScriptTag(txtDemeritDrivername5.Text);
        txtTotalpoints5.Text = General.ClearScriptTag(txtTotalpoints5.Text);
        txtOffencetype1.Text = General.ClearScriptTag(txtOffencetype1.Text);

        txtDemeritDrivername6.Text = General.ClearScriptTag(txtDemeritDrivername6.Text);
        txtTotalpoints6.Text = General.ClearScriptTag(txtTotalpoints6.Text);
        txtOffencetype6.Text = General.ClearScriptTag(txtOffencetype6.Text);


        #region Hire Purchase
        if (rdoYesHirePurchase.Checked)
        {
            rfvHirePurchaseCompany.Enabled = true;
        }
        else
        {
            rfvHirePurchaseCompany.Enabled = false;
        }
        #endregion

        #region Drive in West Malasia
        if (rdoYesDrivingWestMalaysia.Checked)
        {
            rfvDrivetowestmalaysia.Enabled = true;
        }
        else
        {
            rfvDrivetowestmalaysia.Enabled = false;
        }
        #endregion

        #region Vechicle Modified
        if (rdoYesVechicleModification.Checked)
        {
            rfvVMReason.Enabled = true;
        }
        else
        {
            rfvVMReason.Enabled = false;
        }
        #endregion

        #region Sunroof Extension
        if (rdoYesSunRoofExtension.Checked)
        {
            rfvSunroofExtenAmt.Enabled = true;
            revSunroofExtenAmt.Enabled = true;
        }
        else
        {
            rfvSunroofExtenAmt.Enabled = false;
            revSunroofExtenAmt.Enabled = false;
        }
        #endregion

        #region Moonroof Extension
        if (rdoYesMoonRoofExtension.Checked)
        {
            rfvMoonroofExtenAmt.Enabled = true;
            revMoonroofExtenAmt.Enabled = true;
        }
        else
        {
            rfvMoonroofExtenAmt.Enabled = false;
            revMoonroofExtenAmt.Enabled = false;
        }
        #endregion

        #region Physical Infirmity
        if (rdoYesPhysicalinfirm.Checked)
        {
            rfvPIReason.Enabled = true;
        }
        else
        {
            rfvPIReason.Enabled = false;
        }
        #endregion

        #region Accident Last 3 Yrs

        if (rdoYesAccident.Checked)
        {
            rfvAIReason.Enabled = true;
        }
        else
        {
            rfvAIReason.Enabled = false;
        }
        #endregion

        #region Traffic Convicted Fine

        if (rdoYesTraffic.Checked)
        {
            rfvTCReason.Enabled = true;
        }
        else
        {
            rfvTCReason.Enabled = false;
        }
        #endregion

        #region Insurance Terminated
        if (rdoYesInsuranceterminated.Checked)
        {
            rfvITReason.Enabled = true;
        }
        else
        {
            rfvITReason.Enabled = false;
        }
        #endregion

        #region Demerit Points
        if (rdoYesDermeritPoints.Checked)
        {
            rfvDemeritDrivername1.Enabled = true;
            rfvTotalpoints1.Enabled = true;
            ddlDODemerit1.IsEnableValidation(true);
            rfvOffencetype1.Enabled = true;

            if (txtDemeritDrivername2.Text != string.Empty && txtTotalpoints2.Text != string.Empty && txtOffencetype2.Text != string.Empty)
            {
                ddlDODemerit2.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit2.IsEnableValidation(false);
            }
            if (txtDemeritDrivername3.Text != string.Empty && txtTotalpoints3.Text != string.Empty && txtOffencetype3.Text != string.Empty)
            {
                ddlDODemerit3.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit3.IsEnableValidation(false);
            }
            if (txtDemeritDrivername4.Text != string.Empty && txtTotalpoints4.Text != string.Empty && txtOffencetype4.Text != string.Empty)
            {
                ddlDODemerit4.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit4.IsEnableValidation(false);
            }
            if (txtDemeritDrivername5.Text != string.Empty && txtTotalpoints5.Text != string.Empty && txtOffencetype5.Text != string.Empty)
            {
                ddlDODemerit5.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit5.IsEnableValidation(false);
            }
            if (txtDemeritDrivername6.Text != string.Empty && txtTotalpoints6.Text != string.Empty && txtOffencetype6.Text != string.Empty)
            {
                ddlDODemerit6.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit6.IsEnableValidation(false);
            }
        }
        else
        {
            rfvDemeritDrivername1.Enabled = false;
            rfvTotalpoints1.Enabled = false;
            ddlDODemerit1.IsEnableValidation(false);
            rfvOffencetype1.Enabled = false;
            ddlDODemerit2.IsEnableValidation(false);
            ddlDODemerit3.IsEnableValidation(false);
            ddlDODemerit4.IsEnableValidation(false);
            ddlDODemerit5.IsEnableValidation(false);
            ddlDODemerit6.IsEnableValidation(false);
        }
        #endregion

        #region Existing Insurer
        //if (rdoYesExistingInsurer.Checked)
        if(ddlExistingInsurerName.Text != "177")
        {
            rfvExistingInsurerName.Enabled = true;
            rfvInsRegisterNo.Enabled = true;
            rfvInsPolicyNo.Enabled = true;
            ddlDOCancellation.IsEnableValidation(true);
            rfvExistNCD.Enabled = true;
        }
        else
        {
            rfvExistingInsurerName.Enabled = true;
            rfvInsRegisterNo.Enabled = false;
            rfvInsPolicyNo.Enabled = false;
            ddlDOCancellation.IsEnableValidation(false);
            rfvExistNCD.Enabled = false;
        }
        #endregion

        #region ClaimAmount
        if (lblAnyclaim.Text.Trim() != "No")
        {
            rfvClaimODAmount.Enabled = true;
            revClaimODAmount.Enabled = true;
            rfvClaimTPPDAmount.Enabled = true;
            revClaimTPPDAmount.Enabled = true;
        }
        else
        {
            rfvClaimODAmount.Enabled = false;
            revClaimODAmount.Enabled = false;
            rfvClaimTPPDAmount.Enabled = false;
            revClaimTPPDAmount.Enabled = false;
        }
        #endregion
    }

    private void ChangeValidationEffectServerSide(string strValidationGroup)
    {
        #region Proposal Details
        //Applicant's Salutation
        ddlSalutation.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvName.Enabled && rfvName.ValidationGroup == strValidationGroup)
        {
            rfvName.Validate();
            if (rfvName.IsValid == false)
            {
                txtName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtName.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtName.ControlStyle.CssClass = "";
        }

        if (revName.Enabled && revName.ValidationGroup == strValidationGroup)
        {
            if (rfvName.IsValid)
            {
                revName.Validate();
                if (revName.IsValid == false)
                {
                    txtName.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtName.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtName.ControlStyle.CssClass = "";
        }

        //Applicant's Id Number
        ddlIdNumber.ChangeValidationEffectServerSide(strValidationGroup);

        //Applicant's Nationality
        ddlNationality.ChangeValidationEffectServerSide(strValidationGroup);

        //Postal Code
        if (rfvPostCode.Enabled && rfvPostCode.ValidationGroup == strValidationGroup)
        {
            rfvPostCode.Validate();
            if (rfvPostCode.IsValid == false)
            {
                txtPostCode.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtPostCode.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "";
        }

        if (revPostCode.Enabled && revPostCode.ValidationGroup == strValidationGroup)
        {
            if (rfvPostCode.IsValid)
            {
                revPostCode.Validate();
                if (revPostCode.IsValid == false)
                {
                    txtPostCode.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtPostCode.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "";
        }

        //Unit No
        if (rfvUnit1.Enabled && rfvUnit1.ValidationGroup == strValidationGroup)
        {
            rfvUnit1.Validate();
            if (rfvUnit1.IsValid == false)
            {
                txtUnit1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtUnit1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtUnit1.ControlStyle.CssClass = "";
        }

        //Home No
        if (rfvUnit2.Enabled && rfvUnit2.ValidationGroup == strValidationGroup)
        {
            rfvUnit2.Validate();
            if (rfvUnit2.IsValid == false)
            {
                txtUnit2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtUnit2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtUnit2.ControlStyle.CssClass = "";
        }

        //Address
        if (rfvAddress.Enabled && rfvAddress.ValidationGroup == strValidationGroup)
        {
            rfvAddress.Validate();
            if (rfvAddress.IsValid == false)
            {
                txtAddress.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtAddress.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtAddress.ControlStyle.CssClass = "";
        }

        //Applicant's Mobile Number
        txtMobileNo.ChangeValidationEffectServerSide(strValidationGroup);
        txtOfficePhoneNo.ChangeValidationEffectServerSide(strValidationGroup);
        txtResidentialPhoneNo.ChangeValidationEffectServerSide(strValidationGroup);
        txtFaxNo.ChangeValidationEffectServerSide(strValidationGroup);

        //Licence Number
        if (rfvDrivingLicenceNo.Enabled && rfvDrivingLicenceNo.ValidationGroup == strValidationGroup)
        {
            rfvDrivingLicenceNo.Validate();
            if (rfvDrivingLicenceNo.IsValid == false)
            {
                txtDrivingLicenceNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDrivingLicenceNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDrivingLicenceNo.ControlStyle.CssClass = "";
        }

        //Licence Class
        if (rfvDrivingClass.Enabled && rfvDrivingClass.ValidationGroup == strValidationGroup)
        {
            rfvDrivingClass.Validate();
            if (rfvDrivingClass.IsValid == false)
            {
                txtDrivingClass.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDrivingClass.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDrivingClass.ControlStyle.CssClass = "";
        }

        //Licence - Year of Obtained
        if (rfvYearObtained.Enabled && rfvYearObtained.ValidationGroup == strValidationGroup)
        {
            rfvYearObtained.Validate();
            if (rfvYearObtained.IsValid == false)
            {
                ddlYearObtained.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlYearObtained.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlYearObtained.ControlStyle.CssClass = "";
        }

        #endregion

        #region Vechicle Details
        //Vehicle Status
        if (rfvVehicleStatus.Enabled && rfvVehicleStatus.ValidationGroup == strValidationGroup)
        {
            rfvVehicleStatus.Validate();
            if (rfvVehicleStatus.IsValid == false)
            {
                lblNew.ControlStyle.CssClass = "validationError";
                lblUsed.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblNew.ControlStyle.CssClass = "";
                lblUsed.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblNew.ControlStyle.CssClass = "";
            lblUsed.ControlStyle.CssClass = "";
        }

        //VehicleNo
        if (rfvVehicleNo.Enabled && rfvVehicleNo.ValidationGroup == strValidationGroup)
        {
            rfvVehicleNo.Validate();
            if (rfvVehicleNo.IsValid == false)
            {
                txtVehicleNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtVehicleNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtVehicleNo.ControlStyle.CssClass = "";
        }

        //EngineNo
        if (rfvEngineNo.Enabled && rfvEngineNo.ValidationGroup == strValidationGroup)
        {
            rfvEngineNo.Validate();
            if (rfvEngineNo.IsValid == false)
            {
                txtEngineNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtEngineNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtEngineNo.ControlStyle.CssClass = "";
        }
        //ChassisNo
        if (rfvChassisNo.Enabled && rfvChassisNo.ValidationGroup == strValidationGroup)
        {
            rfvChassisNo.Validate();
            if (rfvChassisNo.IsValid == false)
            {
                txtChassisNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtChassisNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtChassisNo.ControlStyle.CssClass = "";
        }

        //Vehicle Transmission
        if (rfvVehicleTransmission.Enabled && rfvVehicleTransmission.ValidationGroup == strValidationGroup)
        {
            rfvVehicleTransmission.Validate();
            if (rfvVehicleTransmission.IsValid == false)
            {
                ddlVehicleTransmission.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlVehicleTransmission.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlVehicleTransmission.ControlStyle.CssClass = "";
        }

        //Vehicle Propellant
        if (rfvVehiclePropellant.Enabled && rfvVehiclePropellant.ValidationGroup == strValidationGroup)
        {
            rfvVehiclePropellant.Validate();
            if (rfvVehiclePropellant.IsValid == false)
            {
                ddlVehiclePropellant.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlVehiclePropellant.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlVehiclePropellant.ControlStyle.CssClass = "";
        }

        //Vehicle SumInsured
        if (rfvVehicleSumInsured.Enabled && rfvVehicleSumInsured.ValidationGroup == strValidationGroup)
        {
            rfvVehicleSumInsured.Validate();
            if (rfvVehicleSumInsured.IsValid == false)
            {
                txtVehicleSumInsured.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtVehicleSumInsured.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtVehicleSumInsured.ControlStyle.CssClass = "";
        }

        if (revVehicleSumInsured.Enabled && revVehicleSumInsured.ValidationGroup == strValidationGroup)
        {
            if (rfvVehicleSumInsured.IsValid)
            {
                revVehicleSumInsured.Validate();
                if (revVehicleSumInsured.IsValid == false)
                {
                    txtVehicleSumInsured.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtVehicleSumInsured.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtVehicleSumInsured.ControlStyle.CssClass = "";
        }

        //ClaimODAmount
        if (rfvClaimODAmount.Enabled && rfvClaimODAmount.ValidationGroup == strValidationGroup)
        {
            rfvClaimODAmount.Validate();
            if (rfvClaimODAmount.IsValid == false)
            {
                txtClaimODAmount.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtClaimODAmount.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtClaimODAmount.ControlStyle.CssClass = "";
        }

        if (revClaimODAmount.Enabled && revClaimODAmount.ValidationGroup == strValidationGroup)
        {
            if (rfvClaimODAmount.IsValid)
            {
                revClaimODAmount.Validate();
                if (revClaimODAmount.IsValid == false)
                {
                    txtClaimODAmount.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtClaimODAmount.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtClaimODAmount.ControlStyle.CssClass = "";
        }

        //ClaimTPPDAmount
        if (rfvClaimTPPDAmount.Enabled && rfvClaimTPPDAmount.ValidationGroup == strValidationGroup)
        {
            rfvClaimTPPDAmount.Validate();
            if (rfvClaimTPPDAmount.IsValid == false)
            {
                txtClaimTPPDAmount.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtClaimTPPDAmount.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtClaimTPPDAmount.ControlStyle.CssClass = "";
        }

        if (revClaimTPPDAmount.Enabled && revClaimTPPDAmount.ValidationGroup == strValidationGroup)
        {
            if (rfvClaimTPPDAmount.IsValid)
            {
                revClaimTPPDAmount.Validate();
                if (revClaimTPPDAmount.IsValid == false)
                {
                    txtClaimTPPDAmount.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtClaimTPPDAmount.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtClaimTPPDAmount.ControlStyle.CssClass = "";
        }

        //Policy RDC Opted
        if (rfvPolicyRDCOpted.Enabled && rfvPolicyRDCOpted.ValidationGroup == strValidationGroup)
        {
            rfvPolicyRDCOpted.Validate();
            if (rfvPolicyRDCOpted.IsValid == false)
            {
                lblYesPolicyRDCOpted.ControlStyle.CssClass = "validationError";
                lblNoPolicyRDCOpted.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesPolicyRDCOpted.ControlStyle.CssClass = "";
                lblNoPolicyRDCOpted.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesPolicyRDCOpted.ControlStyle.CssClass = "";
            lblNoPolicyRDCOpted.ControlStyle.CssClass = "";
        }

        //Hire Purchase
        if (rfvHirePurchase.Enabled && rfvHirePurchase.ValidationGroup == strValidationGroup)
        {
            rfvHirePurchase.Validate();
            if (rfvHirePurchase.IsValid == false)
            {
                lblYesHirePurchase.ControlStyle.CssClass = "validationError";
                lblNoHirePurchase.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesHirePurchase.ControlStyle.CssClass = "";
                lblNoHirePurchase.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesHirePurchase.ControlStyle.CssClass = "";
            lblNoHirePurchase.ControlStyle.CssClass = "";
        }
        //HirePurchaseCompany
        if (rfvHirePurchaseCompany.Enabled && rfvHirePurchaseCompany.ValidationGroup == strValidationGroup)
        {
            rfvHirePurchaseCompany.Validate();
            if (rfvHirePurchaseCompany.IsValid == false)
            {
                ddlHirePurchaseCompany.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlHirePurchaseCompany.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlHirePurchaseCompany.ControlStyle.CssClass = "";
        }

        //Drive in west malaysia
        if (rfvDrivingWestMalaysia.Enabled && rfvDrivingWestMalaysia.ValidationGroup == strValidationGroup)
        {
            rfvDrivingWestMalaysia.Validate();
            if (rfvDrivingWestMalaysia.IsValid == false)
            {
                lblYesDrivingWestMalaysia.ControlStyle.CssClass = "validationError";
                lblNoDrivingWestMalaysia.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesDrivingWestMalaysia.ControlStyle.CssClass = "";
                lblNoDrivingWestMalaysia.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesDrivingWestMalaysia.ControlStyle.CssClass = "";
            lblNoDrivingWestMalaysia.ControlStyle.CssClass = "";
        }
        //Drive in west malaysia - How often?
        if (rfvDrivetowestmalaysia.Enabled && rfvDrivetowestmalaysia.ValidationGroup == strValidationGroup)
        {
            rfvDrivetowestmalaysia.Validate();
            if (rfvDrivetowestmalaysia.IsValid == false)
            {
                ddlDrivetowestmalaysia.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlDrivetowestmalaysia.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlDrivetowestmalaysia.ControlStyle.CssClass = "";
        }

        //Vechicle Modification
        if (rfvVechicleModification.Enabled && rfvVechicleModification.ValidationGroup == strValidationGroup)
        {
            rfvVechicleModification.Validate();
            if (rfvVechicleModification.IsValid == false)
            {
                lblYesVechicleModification.ControlStyle.CssClass = "validationError";
                lblNoVechicleModification.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesVechicleModification.ControlStyle.CssClass = "";
                lblNoVechicleModification.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesVechicleModification.ControlStyle.CssClass = "";
            lblNoVechicleModification.ControlStyle.CssClass = "";
        }
        //Vechicle Modification Reason
        if (rfvVMReason.Enabled && rfvVMReason.ValidationGroup == strValidationGroup)
        {
            rfvVMReason.Validate();
            if (rfvVMReason.IsValid == false)
            {
                txtVMReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtVMReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtVMReason.ControlStyle.CssClass = "";
        }
        //SunRoof Extension
        if (rfvSunroofExtenAmt.Enabled && rfvSunroofExtenAmt.ValidationGroup == strValidationGroup)
        {
            rfvSunroofExtenAmt.Validate();
            if (rfvSunroofExtenAmt.IsValid == false)
            {
                txtSunroofExtenAmt.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtSunroofExtenAmt.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtSunroofExtenAmt.ControlStyle.CssClass = "";
        }
        if (revSunroofExtenAmt.Enabled && revSunroofExtenAmt.ValidationGroup == strValidationGroup)
        {
            if (rfvSunroofExtenAmt.IsValid)
            {
                revSunroofExtenAmt.Validate();
                if (revSunroofExtenAmt.IsValid == false)
                {
                    txtSunroofExtenAmt.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtSunroofExtenAmt.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtSunroofExtenAmt.ControlStyle.CssClass = "";
        }

        //MoonRoof Extension
        if (rfvMoonroofExtenAmt.Enabled && rfvMoonroofExtenAmt.ValidationGroup == strValidationGroup)
        {
            rfvMoonroofExtenAmt.Validate();
            if (rfvMoonroofExtenAmt.IsValid == false)
            {
                txtMoonroofExtenAmt.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtMoonroofExtenAmt.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtMoonroofExtenAmt.ControlStyle.CssClass = "";
        }
        if (revMoonroofExtenAmt.Enabled && revMoonroofExtenAmt.ValidationGroup == strValidationGroup)
        {
            if (rfvMoonroofExtenAmt.IsValid)
            {
                revMoonroofExtenAmt.Validate();
                if (revMoonroofExtenAmt.IsValid == false)
                {
                    txtMoonroofExtenAmt.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtMoonroofExtenAmt.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtMoonroofExtenAmt.ControlStyle.CssClass = "";
        }

        #endregion

        #region General Question

        //Purpose of use
        if (rfvPurposeofuse.Enabled && rfvPurposeofuse.ValidationGroup == strValidationGroup)
        {
            rfvPurposeofuse.Validate();
            if (rfvPurposeofuse.IsValid == false)
            {
                lblYesPurposeofuse.ControlStyle.CssClass = "validationError";
                lblNoPurposeofuse.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesPurposeofuse.ControlStyle.CssClass = "";
                lblNoPurposeofuse.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesPurposeofuse.ControlStyle.CssClass = "";
            lblNoPurposeofuse.ControlStyle.CssClass = "";
        }
        //Physical infirmty
        if (rfvPhysicalinfirm.Enabled && rfvPhysicalinfirm.ValidationGroup == strValidationGroup)
        {
            rfvPhysicalinfirm.Validate();
            if (rfvPhysicalinfirm.IsValid == false)
            {
                lblYesPhysicalinfirm.ControlStyle.CssClass = "validationError";
                lblNoPhysicalinfirm.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesPhysicalinfirm.ControlStyle.CssClass = "";
                lblNoPhysicalinfirm.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesPhysicalinfirm.ControlStyle.CssClass = "";
            lblNoPhysicalinfirm.ControlStyle.CssClass = "";
        }
        //Physical infirmty Reason
        if (rfvPIReason.Enabled && rfvPIReason.ValidationGroup == strValidationGroup)
        {
            rfvPIReason.Validate();
            if (rfvPIReason.IsValid == false)
            {
                txtPIReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtPIReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtPIReason.ControlStyle.CssClass = "";
        }
        //Accident
        if (rfvAccident.Enabled && rfvAccident.ValidationGroup == strValidationGroup)
        {
            rfvAccident.Validate();
            if (rfvAccident.IsValid == false)
            {
                lblYesAccident.ControlStyle.CssClass = "validationError";
                lblNoAccident.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesAccident.ControlStyle.CssClass = "";
                lblNoAccident.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesAccident.ControlStyle.CssClass = "";
            lblNoAccident.ControlStyle.CssClass = "";
        }
        //AccidentReason
        if (rfvAIReason.Enabled && rfvAIReason.ValidationGroup == strValidationGroup)
        {
            rfvAIReason.Validate();
            if (rfvAIReason.IsValid == false)
            {
                txtAIReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtAIReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtAIReason.ControlStyle.CssClass = "";
        }
        //Traffic
        if (rfvTraffic.Enabled && rfvTraffic.ValidationGroup == strValidationGroup)
        {
            rfvTraffic.Validate();
            if (rfvTraffic.IsValid == false)
            {
                lblYesTraffic.ControlStyle.CssClass = "validationError";
                lblNoTraffic.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesTraffic.ControlStyle.CssClass = "";
                lblNoTraffic.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesTraffic.ControlStyle.CssClass = "";
            lblNoTraffic.ControlStyle.CssClass = "";
        }
        //TrafficReason
        if (rfvTCReason.Enabled && rfvTCReason.ValidationGroup == strValidationGroup)
        {
            rfvTCReason.Validate();
            if (rfvTCReason.IsValid == false)
            {
                txtTCReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtTCReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtTCReason.ControlStyle.CssClass = "";
        }

        //DermeritPoints
        if (rfvDermeritPoints.Enabled && rfvDermeritPoints.ValidationGroup == strValidationGroup)
        {
            rfvDermeritPoints.Validate();
            if (rfvDermeritPoints.IsValid == false)
            {
                lblYesDermeritPoints.ControlStyle.CssClass = "validationError";
                lblNoDermeritPoints.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesDermeritPoints.ControlStyle.CssClass = "";
                lblNoDermeritPoints.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesDermeritPoints.ControlStyle.CssClass = "";
            lblNoDermeritPoints.ControlStyle.CssClass = "";
        }
        //Drivername
        if (rfvDemeritDrivername1.Enabled && rfvDemeritDrivername1.ValidationGroup == strValidationGroup)
        {
            rfvDemeritDrivername1.Validate();
            if (rfvDemeritDrivername1.IsValid == false)
            {
                txtDemeritDrivername1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDemeritDrivername1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDemeritDrivername1.ControlStyle.CssClass = "";
        }
        //Totalpoints
        if (rfvTotalpoints1.Enabled && rfvTotalpoints1.ValidationGroup == strValidationGroup)
        {
            rfvTotalpoints1.Validate();
            if (rfvTotalpoints1.IsValid == false)
            {
                txtTotalpoints1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtTotalpoints1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtTotalpoints1.ControlStyle.CssClass = "";
        }
        //Offencetype
        if (rfvOffencetype1.Enabled && rfvOffencetype1.ValidationGroup == strValidationGroup)
        {
            rfvOffencetype1.Validate();
            if (rfvOffencetype1.IsValid == false)
            {
                txtOffencetype1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtOffencetype1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtOffencetype1.ControlStyle.CssClass = "";
        }
        //Date Of Demerit 1
        ddlDODemerit1.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 2
        ddlDODemerit2.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 3
        ddlDODemerit3.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 4
        ddlDODemerit4.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 5
        ddlDODemerit5.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 6
        ddlDODemerit6.ChangeValidationEffectServerSide(strValidationGroup);

        //Insurance Terminated
        if (rfvInsuranceterminated.Enabled && rfvInsuranceterminated.ValidationGroup == strValidationGroup)
        {
            rfvInsuranceterminated.Validate();
            if (rfvInsuranceterminated.IsValid == false)
            {
                lblYesInsuranceterminated.ControlStyle.CssClass = "validationError";
                lblNoInsuranceterminated.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesInsuranceterminated.ControlStyle.CssClass = "";
                lblNoInsuranceterminated.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesInsuranceterminated.ControlStyle.CssClass = "";
            lblNoInsuranceterminated.ControlStyle.CssClass = "";
        }
        //Insurance Terminated Reason
        if (rfvITReason.Enabled && rfvITReason.ValidationGroup == strValidationGroup)
        {
            rfvITReason.Validate();
            if (rfvITReason.IsValid == false)
            {
                txtITReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtITReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtITReason.ControlStyle.CssClass = "";
        }


        #endregion

        #region Details of Previous Insurance
        //Previous Insurance
        //if (rfvExistingInsurer.Enabled && rfvExistingInsurer.ValidationGroup == strValidationGroup)
        //{
        //    rfvExistingInsurer.Validate();
        //    if (rfvExistingInsurer.IsValid == false)
        //    {
        //        lblYesExistingInsurer.ControlStyle.CssClass = "validationError";
        //        lblNoExistingInsurer.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        lblYesExistingInsurer.ControlStyle.CssClass = "";
        //        lblNoExistingInsurer.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    lblYesExistingInsurer.ControlStyle.CssClass = "";
        //    lblNoExistingInsurer.ControlStyle.CssClass = "";
        //}
        //ExistingInsurerName
        if (rfvExistingInsurerName.Enabled && rfvExistingInsurerName.ValidationGroup == strValidationGroup)
        {
            rfvExistingInsurerName.Validate();
            if (rfvExistingInsurerName.IsValid == false)
            {
                ddlExistingInsurerName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlExistingInsurerName.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlExistingInsurerName.ControlStyle.CssClass = "";
        }
        //Existing InsRegisterNo
        if (rfvInsRegisterNo.Enabled && rfvInsRegisterNo.ValidationGroup == strValidationGroup)
        {
            rfvInsRegisterNo.Validate();
            if (rfvInsRegisterNo.IsValid == false)
            {
                txtInsRegisterNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtInsRegisterNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtInsRegisterNo.ControlStyle.CssClass = "";
        }
        //Existing InsPolicyNo
        if (rfvInsPolicyNo.Enabled && rfvInsPolicyNo.ValidationGroup == strValidationGroup)
        {
            rfvInsPolicyNo.Validate();
            if (rfvInsPolicyNo.IsValid == false)
            {
                txtInsPolicyNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtInsPolicyNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtInsPolicyNo.ControlStyle.CssClass = "";
        }
        //Existing NCD
        if (rfvExistNCD.Enabled && rfvExistNCD.ValidationGroup == strValidationGroup)
        {
            rfvExistNCD.Validate();
            if (rfvExistNCD.IsValid == false)
            {
                ddlExistNCD.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlExistNCD.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlExistNCD.ControlStyle.CssClass = "";
        }
        //DOCancellation
        ddlDOCancellation.ChangeValidationEffectServerSide(strValidationGroup);

        #endregion

        #region Payment Mode

        //Name of the Card
        if (rfvNameoftheCard.Enabled && rfvNameoftheCard.ValidationGroup == strValidationGroup)
        {
            rfvNameoftheCard.Validate();
            if (rfvNameoftheCard.IsValid == false)
            {
                txtNameoftheCard.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNameoftheCard.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNameoftheCard.ControlStyle.CssClass = "";
        }
        //Issuing Bank
        if (rfvIssuingBank.Enabled && rfvIssuingBank.ValidationGroup == strValidationGroup)
        {
            rfvIssuingBank.Validate();
            if (rfvIssuingBank.IsValid == false)
            {
                txtIssuingBank.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtIssuingBank.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtIssuingBank.ControlStyle.CssClass = "";
        }
        //Card 1
        if (rfvCardNo1.Enabled && rfvCardNo1.ValidationGroup == strValidationGroup)
        {
            rfvCardNo1.Validate();
            if (rfvCardNo1.IsValid == false)
            {
                txtCardNo1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo1.ControlStyle.CssClass = "";
        }

        if (revCardNo1.Enabled && revCardNo1.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo1.IsValid)
            {
                revCardNo1.Validate();
                if (revCardNo1.IsValid == false)
                {
                    txtCardNo1.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo1.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo1.ControlStyle.CssClass = "";
        }
        //Card 2
        if (rfvCardNo2.Enabled && rfvCardNo2.ValidationGroup == strValidationGroup)
        {
            rfvCardNo2.Validate();
            if (rfvCardNo2.IsValid == false)
            {
                txtCardNo2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo2.ControlStyle.CssClass = "";
        }

        if (revCardNo2.Enabled && revCardNo2.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo2.IsValid)
            {
                revCardNo2.Validate();
                if (revCardNo2.IsValid == false)
                {
                    txtCardNo2.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo2.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo2.ControlStyle.CssClass = "";
        }
        //Card 3
        if (rfvCardNo3.Enabled && rfvCardNo3.ValidationGroup == strValidationGroup)
        {
            rfvCardNo3.Validate();
            if (rfvCardNo3.IsValid == false)
            {
                txtCardNo3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo3.ControlStyle.CssClass = "";
        }

        if (revCardNo3.Enabled && revCardNo3.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo3.IsValid)
            {
                revCardNo3.Validate();
                if (revCardNo3.IsValid == false)
                {
                    txtCardNo3.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo3.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo3.ControlStyle.CssClass = "";
        }
        //Card 4
        if (rfvCardNo4.Enabled && rfvCardNo4.ValidationGroup == strValidationGroup)
        {
            rfvCardNo4.Validate();
            if (rfvCardNo4.IsValid == false)
            {
                txtCardNo4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo4.ControlStyle.CssClass = "";
        }

        if (revCardNo4.Enabled && revCardNo4.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo4.IsValid)
            {
                revCardNo4.Validate();
                if (revCardNo4.IsValid == false)
                {
                    txtCardNo4.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo4.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo4.ControlStyle.CssClass = "";
        }
        //Card Expiry Month
        if (rfvCardExpiryMonth.Enabled && rfvCardExpiryMonth.ValidationGroup == strValidationGroup)
        {
            rfvCardExpiryMonth.Validate();
            if (rfvCardExpiryMonth.IsValid == false)
            {
                ddlCardExpiryMonth.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlCardExpiryMonth.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlCardExpiryMonth.ControlStyle.CssClass = "";
        }


        //Card Expiry Year
        if (rfvCardExpiryYear.Enabled && rfvCardExpiryYear.ValidationGroup == strValidationGroup)
        {
            rfvCardExpiryYear.Validate();
            if (rfvCardExpiryYear.IsValid == false)
            {
                ddlCardExpiryYear.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlCardExpiryYear.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlCardExpiryYear.ControlStyle.CssClass = "";
        }

        //CardType
        if (rfvCardType.Enabled && rfvCardType.ValidationGroup == strValidationGroup)
        {
            rfvCardType.Validate();
            if (rfvCardType.IsValid == false)
            {
                lblVisa.ControlStyle.CssClass = "validationError";
                lblMasterCard.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblVisa.ControlStyle.CssClass = "";
                lblMasterCard.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblVisa.ControlStyle.CssClass = "";
            lblMasterCard.ControlStyle.CssClass = "";
        }

        #endregion

        #region Drivers
        //Driver 1 **************************************************************
        //Name
        if (rfvDriverName1.Enabled && rfvDriverName1.ValidationGroup == strValidationGroup)
        {
            rfvDriverName1.Validate();
            if (rfvDriverName1.IsValid == false)
            {
                txtDriverName1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverName1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverName1.ControlStyle.CssClass = "";
        }
        //Relation
        ddlDriverRelation1.ChangeValidationEffectServerSide(strValidationGroup);
        //Driving Class
        if (rfvDriverDrivingClass1.Enabled && rfvDriverDrivingClass1.ValidationGroup == strValidationGroup)
        {
            rfvDriverDrivingClass1.Validate();
            if (rfvDriverDrivingClass1.IsValid == false)
            {
                txtDriverDrivingClass1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverDrivingClass1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverDrivingClass1.ControlStyle.CssClass = "";
        }
        //Driving Year Obtained
        if (rfvDriverYearObtained1.Enabled && rfvDriverYearObtained1.ValidationGroup == strValidationGroup)
        {
            rfvDriverYearObtained1.Validate();
            if (rfvDriverYearObtained1.IsValid == false)
            {
                ddlDriverYearObtained1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlDriverYearObtained1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlDriverYearObtained1.ControlStyle.CssClass = "";
        }

        //Driver 2 **************************************************************
        //Name
        if (rfvDriverName2.Enabled && rfvDriverName2.ValidationGroup == strValidationGroup)
        {
            rfvDriverName2.Validate();
            if (rfvDriverName2.IsValid == false)
            {
                txtDriverName2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverName2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverName2.ControlStyle.CssClass = "";
        }
        //Relation
        ddlDriverRelation2.ChangeValidationEffectServerSide(strValidationGroup);
        //Driving Class
        if (rfvDriverDrivingClass2.Enabled && rfvDriverDrivingClass2.ValidationGroup == strValidationGroup)
        {
            rfvDriverDrivingClass2.Validate();
            if (rfvDriverDrivingClass2.IsValid == false)
            {
                txtDriverDrivingClass2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverDrivingClass2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverDrivingClass2.ControlStyle.CssClass = "";
        }
        //Driving Year Obtained
        if (rfvDriverYearObtained2.Enabled && rfvDriverYearObtained2.ValidationGroup == strValidationGroup)
        {
            rfvDriverYearObtained2.Validate();
            if (rfvDriverYearObtained2.IsValid == false)
            {
                ddlDriverYearObtained2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlDriverYearObtained2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlDriverYearObtained2.ControlStyle.CssClass = "";
        }

        //Driver 3 **************************************************************
        //Name
        if (rfvDriverName3.Enabled && rfvDriverName3.ValidationGroup == strValidationGroup)
        {
            rfvDriverName3.Validate();
            if (rfvDriverName3.IsValid == false)
            {
                txtDriverName3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverName3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverName3.ControlStyle.CssClass = "";
        }
        //Relation
        ddlDriverRelation3.ChangeValidationEffectServerSide(strValidationGroup);
        //Driving Class
        if (rfvDriverDrivingClass3.Enabled && rfvDriverDrivingClass3.ValidationGroup == strValidationGroup)
        {
            rfvDriverDrivingClass3.Validate();
            if (rfvDriverDrivingClass3.IsValid == false)
            {
                txtDriverDrivingClass3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverDrivingClass3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverDrivingClass3.ControlStyle.CssClass = "";
        }
        //Driving Year Obtained
        if (rfvDriverYearObtained3.Enabled && rfvDriverYearObtained3.ValidationGroup == strValidationGroup)
        {
            rfvDriverYearObtained3.Validate();
            if (rfvDriverYearObtained3.IsValid == false)
            {
                ddlDriverYearObtained3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlDriverYearObtained3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlDriverYearObtained3.ControlStyle.CssClass = "";
        }

        //Driver 4 **************************************************************
        //Name
        if (rfvDriverName4.Enabled && rfvDriverName4.ValidationGroup == strValidationGroup)
        {
            rfvDriverName4.Validate();
            if (rfvDriverName4.IsValid == false)
            {
                txtDriverName4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverName4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverName4.ControlStyle.CssClass = "";
        }
        //Relation
        ddlDriverRelation4.ChangeValidationEffectServerSide(strValidationGroup);
        //Driving Class
        if (rfvDriverDrivingClass4.Enabled && rfvDriverDrivingClass4.ValidationGroup == strValidationGroup)
        {
            rfvDriverDrivingClass4.Validate();
            if (rfvDriverDrivingClass4.IsValid == false)
            {
                txtDriverDrivingClass4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverDrivingClass4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverDrivingClass4.ControlStyle.CssClass = "";
        }
        //Driving Year Obtained
        if (rfvDriverYearObtained4.Enabled && rfvDriverYearObtained4.ValidationGroup == strValidationGroup)
        {
            rfvDriverYearObtained4.Validate();
            if (rfvDriverYearObtained4.IsValid == false)
            {
                ddlDriverYearObtained4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlDriverYearObtained4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlDriverYearObtained4.ControlStyle.CssClass = "";
        }

        //Driver 5 **************************************************************
        //Name
        if (rfvDriverName5.Enabled && rfvDriverName5.ValidationGroup == strValidationGroup)
        {
            rfvDriverName5.Validate();
            if (rfvDriverName5.IsValid == false)
            {
                txtDriverName5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverName5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverName5.ControlStyle.CssClass = "";
        }
        //Relation
        ddlDriverRelation5.ChangeValidationEffectServerSide(strValidationGroup);
        //Driving Class
        if (rfvDriverDrivingClass5.Enabled && rfvDriverDrivingClass5.ValidationGroup == strValidationGroup)
        {
            rfvDriverDrivingClass5.Validate();
            if (rfvDriverDrivingClass5.IsValid == false)
            {
                txtDriverDrivingClass5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverDrivingClass5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverDrivingClass5.ControlStyle.CssClass = "";
        }
        //Driving Year Obtained
        if (rfvDriverYearObtained5.Enabled && rfvDriverYearObtained5.ValidationGroup == strValidationGroup)
        {
            rfvDriverYearObtained5.Validate();
            if (rfvDriverYearObtained5.IsValid == false)
            {
                ddlDriverYearObtained5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlDriverYearObtained5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlDriverYearObtained5.ControlStyle.CssClass = "";
        }

        #endregion

    }

    private bool SaveDemeritPoints()
    {
        //bool _result = false;
        Int64 _demeritresult = 0;
        if (txtDemeritDrivername1.Text != string.Empty && txtTotalpoints1.Text != string.Empty && txtOffencetype1.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = Convert.ToInt64(Session[General.CarId].ToString());
            _cardriverdemeritpoints.CECarMoreDetailId = Convert.ToInt64(Session[CE.Global.General.CarMoreDetailId].ToString());
            _cardriverdemeritpoints.ProviderCompanyId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            _cardriverdemeritpoints.DriverName = txtDemeritDrivername1.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints1.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit1.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype1.Text;
            _cardriverdemeritpoints.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertRsa(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDemeritDrivername2.Text != string.Empty && txtTotalpoints2.Text != string.Empty && txtOffencetype2.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = Convert.ToInt64(Session[General.CarId].ToString());
            _cardriverdemeritpoints.CECarMoreDetailId = Convert.ToInt64(Session[CE.Global.General.CarMoreDetailId].ToString());
            _cardriverdemeritpoints.ProviderCompanyId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            _cardriverdemeritpoints.DriverName = txtDemeritDrivername2.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints2.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit2.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype2.Text;
            _cardriverdemeritpoints.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertRsa(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDemeritDrivername3.Text != string.Empty && txtTotalpoints3.Text != string.Empty && txtOffencetype3.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = Convert.ToInt64(Session[General.CarId].ToString());
            _cardriverdemeritpoints.CECarMoreDetailId = Convert.ToInt64(Session[CE.Global.General.CarMoreDetailId].ToString());
            _cardriverdemeritpoints.ProviderCompanyId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            _cardriverdemeritpoints.DriverName = txtDemeritDrivername3.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints3.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit3.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype3.Text;
            _cardriverdemeritpoints.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertRsa(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDemeritDrivername4.Text != string.Empty && txtTotalpoints4.Text != string.Empty && txtOffencetype4.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = Convert.ToInt64(Session[General.CarId].ToString());
            _cardriverdemeritpoints.CECarMoreDetailId = Convert.ToInt64(Session[CE.Global.General.CarMoreDetailId].ToString());
            _cardriverdemeritpoints.ProviderCompanyId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            _cardriverdemeritpoints.DriverName = txtDemeritDrivername4.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints4.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit4.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype4.Text;
            _cardriverdemeritpoints.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertRsa(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDemeritDrivername5.Text != string.Empty && txtTotalpoints5.Text != string.Empty && txtOffencetype5.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = Convert.ToInt64(Session[General.CarId].ToString());
            _cardriverdemeritpoints.CECarMoreDetailId = Convert.ToInt64(Session[CE.Global.General.CarMoreDetailId].ToString());
            _cardriverdemeritpoints.ProviderCompanyId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            _cardriverdemeritpoints.DriverName = txtDemeritDrivername5.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints5.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit5.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype5.Text;
            _cardriverdemeritpoints.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertRsa(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDemeritDrivername6.Text != string.Empty && txtTotalpoints6.Text != string.Empty && txtOffencetype6.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = Convert.ToInt64(Session[General.CarId].ToString());
            _cardriverdemeritpoints.CECarMoreDetailId = Convert.ToInt64(Session[CE.Global.General.CarMoreDetailId].ToString());
            _cardriverdemeritpoints.ProviderCompanyId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
            _cardriverdemeritpoints.DriverName = txtDemeritDrivername6.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints6.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit6.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype6.Text;
            _cardriverdemeritpoints.RefCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertRsa(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        return _demeritresult > 0;
    }

    private bool UpdateDriverDetails()
    {
        bool _result = false;
        //Int64 _demeritresult = 0;
        CarDriver _cardriver = new CarDriver();
        CarDriverDB _cardriverdb = new CarDriverDB();

        if (txtDriverCount.Text.Trim() != "0")
        {
            int _drivercount = Convert.ToInt32(txtDriverCount.Text.Trim());
            int _insertcount = 0;

            for (int i = 1; i <= _drivercount; i++)
            {
                _cardriver.StepId = 2;
                _cardriver.RerCEUserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
                _cardriver.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
                if (i == 1)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId1.Text.Trim());
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverName1.Text.ToUpper()));
                    _cardriver.Info1 = ddlDriverRelation1.GetRelationship();
                    _cardriver.Info2 = ddlDriverExperienceMonth1.Text;
                    _cardriver.Info3 = Server.HtmlEncode(General.ClearScriptTag(txtDriverDrivingClass1.Text.Trim()));
                    _cardriver.Info4 = ddlDriverYearObtained1.Text;
                    _cardriver.DOB = _dtDOB1;
                    _cardriver.Status = "Active";
                }
                else if (i == 2)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId2.Text.Trim());
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverName2.Text.ToUpper()));
                    _cardriver.Info1 = ddlDriverRelation2.GetRelationship();
                    _cardriver.Info2 = ddlDriverExperienceMonth2.Text;
                    _cardriver.Info3 = Server.HtmlEncode(General.ClearScriptTag(txtDriverDrivingClass2.Text.Trim()));
                    _cardriver.Info4 = ddlDriverYearObtained2.Text;
                    _cardriver.DOB = _dtDOB2;
                    _cardriver.Status = "Active";
                }
                else if (i == 3)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId3.Text.Trim());
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverName3.Text.ToUpper()));
                    _cardriver.Info1 = ddlDriverRelation3.GetRelationship();
                    _cardriver.Info2 = ddlDriverExperienceMonth3.Text;
                    _cardriver.Info3 = Server.HtmlEncode(General.ClearScriptTag(txtDriverDrivingClass3.Text.Trim()));
                    _cardriver.Info4 = ddlDriverYearObtained3.Text;
                    _cardriver.DOB = _dtDOB3;
                    _cardriver.Status = "Active";
                }
                else if (i == 4)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId4.Text.Trim());
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverName4.Text.ToUpper()));
                    _cardriver.Info1 = ddlDriverRelation4.GetRelationship();
                    _cardriver.Info2 = ddlDriverExperienceMonth4.Text;
                    _cardriver.Info3 = Server.HtmlEncode(General.ClearScriptTag(txtDriverDrivingClass4.Text.Trim()));
                    _cardriver.Info4 = ddlDriverYearObtained4.Text;
                    _cardriver.DOB = _dtDOB4;
                    _cardriver.Status = "Active";
                }
                else if (i == 5)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId5.Text.Trim());
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverName5.Text.ToUpper()));
                    _cardriver.Info1 = ddlDriverRelation5.GetRelationship();
                    _cardriver.Info2 = ddlDriverExperienceMonth5.Text;
                    _cardriver.Info3 = Server.HtmlEncode(General.ClearScriptTag(txtDriverDrivingClass5.Text.Trim()));
                    _cardriver.Info4 = ddlDriverYearObtained5.Text;
                    _cardriver.DOB = _dtDOB5;
                    _cardriver.Status = "Active";
                }
                _cardriver.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
                if (_cardriverdb.Insert(_cardriver) > 0)
                {
                    _insertcount++;
                    _result = true;
                }
            }
            _cardriverdb = null;
            _cardriver = null;
        }
        return _result;
    }

    public string Encode(string sData)
    {
        byte[] encData_byte = new byte[sData.Length];
        encData_byte = System.Text.Encoding.UTF8.GetBytes(sData);
        string encodedData = Convert.ToBase64String(encData_byte);
        return encodedData;
    }

    private void ProposalNotification()
    {
        string _strSql, _providerName, _providerEmail, _providerCCEmail, _providerBCCEmail, _Date, _Time, _InsuranceName, _RefNo;
        MyDatabase _db = new MyDatabase();
        DataTable _dtProvider = new DataTable();
        DataTable _dtInsurance = new DataTable();
        _Date = "";
        _Time = "";
        _RefNo = "";
        _strSql = "";
        _providerName = "";
        _providerEmail = "";
        _providerCCEmail = "";
        _providerBCCEmail = "";
        _InsuranceName = "Car Insurance";
        _strSql = "SELECT [CompanyName], [Email1] FROM tblProviderCompany WHERE ProviderCompanyId = " + Session[General.ProviderCompanyId].ToString();
        _dtProvider = _db.GetDataTable(_strSql);
        if (_dtProvider.Rows.Count > 0)
        {
            _providerName = _dtProvider.Rows[0]["CompanyName"].ToString() + " Insurance";
            //_providerEmail = _dtProvider.Rows[0]["Email1"].ToString();
            _providerEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("RSACI_TO");
            _providerCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("RSACI_CC");
            _providerBCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("RSACI_BCC");
        }
        _strSql = "";
        _strSql = "SELECT CONVERT(VARCHAR,ModifiedDate,103) AS [Date], CONVERT(VARCHAR,ModifiedDate,108) AS [Time] ";
        _strSql += " FROM  tblCarMoreDetail_Rsa WHERE CECarId = " + Session[General.CarId].ToString() + " ORDER BY ModifiedDate DESC";
        _dtInsurance = _db.GetDataTable(_strSql);
        if (_dtInsurance.Rows.Count > 0)
        {
            _Date = _dtInsurance.Rows[0]["Date"].ToString();
            _Time = _dtInsurance.Rows[0]["Time"].ToString();
        }
        //_RefNo = General.GetRefNumber("CI", _Date, Session[General.CarId].ToString());
        _RefNo = lblQRefNo.Text.Trim();
        if ((_dtProvider.Rows.Count > 0) && (_dtInsurance.Rows.Count > 0))
        {
            MyMailManager.SendProposalCompleteNotification(_providerName, _providerEmail, _providerCCEmail, _providerBCCEmail, _InsuranceName, _Date, _Time, _RefNo);
        }

    }

    public void SetPremium()
    {
        lblNewPremium1.Text = "New1";
        lblNewPremium2.Text = "New2";
        lblNewPremium3.Text = "New3";
    }

}
